<?php

/**
 * @author toai9
 * @copyright 2011
 */
    require_once('includes/general.php');
    if(!tep_db_checkDb()) die('ko ket noi dc csdl');
$content='';

// phan nay la chuyen muc lam dep

//bat dau phan trang chuyen muc lam dep

$sql2='SELECT count(id) as count FROM `tbl_tin_tuc` where ma_danh_muc_tin_tuc=1 ';
$kq2=tep_db_query($sql2);
$item2=tep_db_fetch_array($kq2);
//bat dau viet phan trang
$display=3;// so san pham xuat hien tren mot trang
$record=$item2['count'];//tong so san pham
if($record>$display){
    $page=ceil($record/$display);
}
else{
    $page=1;
}
#current page, default currnet page = 1
$curPage=isset($_GET['curPage']) && (int)$_GET['curPage']?$_GET['curPage']:1;
# calculate the first index for current page
$start = ($curPage - 1)*$display;

$sql4='select * from tbl_tin_tuc where ma_danh_muc_tin_tuc=1 limit '.$start.', '.$display.'';
$kq4=tep_db_query($sql4);
 $content.='<div class="lamdep">
            <div class="link"><a href="index.php?page=lamdepvasuckhoe">Làm Đẹp Và Sức Khỏe</a> >> <a href="#"> Làm Đẹp</a></div></br>
                    <h1>..:::.. Chuyên mục làm đẹp ..:::..</h1>
                    
                    <div class="block_lamdep">';
                                      
                            /**
 * $sql='select * from tbl_tin_tuc Where ma_danh_muc_tin_tuc =1 ';
 *                             $kq=tep_db_query($sql);
 */
                           
                         
                          while($item=tep_db_fetch_array($kq4)){ 
                         $content.='<div class="chuyenmuclamdep">
                        <a href="index.php?matintuc='.$item['id'].'&amp;maloaitintuc='.$item['ma_danh_muc_tin_tuc'].'"><img src="images/'.$item['hinh_anh'].'" alt="'.$item['hinh_anh'].'"/></a>
                        <h3><a href="index.php?matintuc='.$item['id'].'&amp;maloaitintuc='.$item['ma_danh_muc_tin_tuc'].'" >'.$item['tieu_de'].'</a></h3>
                       
                        <p>'.$item['mo_ta_ngan_gon'].'</p></div>';
                         }
                         
                         $content.='
        <ul class="phantrang">';
         $content.='Trang:';
        $next=$curPage + 1;
        if($next > $page)
            $next = $page;
        $prev=$curPage - 1;
        if($prev < 1)
            $prev = 1;
        $current=($start/$display)+1;
        //hien thi phan trang prev
        if($current!=1){
           $content.='<li><a href="?page=lamdep&amp;maloaitintuc=1&curPage='.$prev.'">Previous</a></li>'; 
        }
         //hien thi trang
         for($i=1;$i<=$page;$i++){     
            if($current!=$i){
                $content.='<li><a href="?page=lamdep&amp;maloaitintuc=1&curPage='.$i.'">'.$i.'</a></li>'; 
             } 
            else
              {
                $content.='<li class="current"><a href="?page=lamdep&amp;maloaitintuc=1&curPage='.$i.'">'.$i.'</a></li>'; 
              }                       
         }
        //hien thi next
        if($current!=$page){
            $content.='<li><a href="?page=lamdep&amp;maloaitintuc=1&curPage='.$next.'">Next</a></li>';  
        }
       $content.=' </ul>'; 
                    $content.='<div class="clear"></div>   
                        </div>  
                                                           
                </div>';
                
 

            
    echo $content;
?>